import numpy as np
from filter import filter_harmonic
import librosa
from matplotlib import pyplot as plt
from draw_FFT import draw_FFT


def draw_chroma(Path):
    freq_axis, amp_filter, sample_rate = filter_harmonic(Path)
    # freq_axis, amp_filter, sample_rate = draw_FFT(Path)
    amp_filter = np.array(amp_filter)
    chromagram = librosa.feature.chroma_stft(y=amp_filter, sr=sample_rate)
    print(chromagram)
    # 绘制色度图
    plt.figure(figsize=(10, 4))
    librosa.display.specshow(chromagram, x_axis='time', y_axis='chroma', cmap='coolwarm')
    plt.colorbar()
    plt.title('Chroma Features')
    plt.tight_layout()
    plt.show()


if __name__ == '__main__':
    path = "../music sample/花海伴奏节选.mp3"
    draw_chroma(path)

